#include<map>
#include<iostream>
#include<string>
using namespace std;
class T1
{
public:
static int get()
{
    return 10;
}
};
class T2
{
    public:
    static string get()
    {
        return "hello,world";
    }
};
template<class T>
void func(void)
{
    //不知道调用那一个类的情况下  泛性编程
    auto ret = T::get();
    cout << "ret:" << ret << endl;
}
//另一种方法
template  <class T,typename P>
void func(void)
{
    P ret = T::get();
    cout << "ret = " << ret << endl;
}
//用于stl容器遍历

int main ()
{
    //Key :int   Value :string
    map<int, string> mp;
    mp.insert(make_pair(1, "ace"));
    mp.insert(make_pair(2, "sabo"));
    mp.insert(make_pair(3, "luffy"));
    //遍历容器
    map<int, string>::iterator it = mp.begin();
    for (; it != mp.end();it++)
    {
        cout << "Key:" << it->first << ", value:" << it->second << endl;
    }
    //通过suto来简化
    auto it1 = mp.begin();
    for (; it1 != mp.end(); it1++)
    {
        cout << "Key:" << it1->first << ", value:" << it1->second << endl;
    }

    func<T1>();
    func<T2>();

    return 0;
}